# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Eric Bélanger <eric@archlinux.org>

pkgname=xaos
pkgver=4.2.1
pkgrel=3
pkgdesc='Interactive fractal zoomer'
arch=(loong64 x86_64)
url='https://xaos-project.github.io/'
license=(GPL2)
makedepends=(gendesk git qt5-tools)
depends=(qt5-base)
source=("git+https://github.com/xaos-project/XaoS#commit=632a48b088326a916e7c6f8fdb4a549ddfcbc7c0") # tag: release-4.2.1
sha256sums=('SKIP')

prepare() {
  # Add missing include
  sed -i '30i#include <cstdlib>' XaoS/src/util/timers.cpp

  # Desktop shortcut
  gendesk -f -n \
    --pkgname=XaoS \
    --pkgdesc="$pkgdesc" \
    --exec=xaos \
    --icon=xaos \
    --categories='Application;Graphics'
}

build() {
  cd XaoS
  export DEFINES='USE_OPENGL USE_FLOAT128'
  qmake && make
}

package() {
  cd XaoS

  # Executable
  install -Dm755 bin/xaos "$pkgdir/usr/bin/xaos"

  # Tutorial and catalogs
  install -d "$pkgdir/usr/share/XaoS/"
  cp -r tutorial catalogs "$pkgdir/usr/share/XaoS"

  # Examples
  install -d "$pkgdir/usr/share/XaoS/examples"
  find examples -name "*.xpf" -exec install -Dm644 -t "$pkgdir"/usr/share/XaoS/examples/ {} \;

  # Desktop shortcut and icon
  install -Dm644 ../XaoS.desktop \
    "$pkgdir/usr/share/applications/$pkgname.desktop"
  install -Dm644 "src/ui/images/xaosbig.png" \
    "$pkgdir/usr/share/pixmaps/$pkgname.png"

  # Man page
  install -Dm644 doc/xaos.6 "$pkgdir/usr/share/man/man6/xaos.6"
}
